/*
 * menu.h
 *
 * Created: 20.03.2013 22:14:46
 *  Author: Timmo
 */ 


#ifndef MENU_H_
#define MENU_H_

#include <stdint.h>


typedef struct {
	uint8_t menulevel:4;
	uint8_t submenuindex:4;
	uint8_t nrsubitems;		
	uint8_t item_type;		//Menu Type
	const char *item_text;	//Text to display
	void *item_ptr;			//Pointer to function or value
	void *item_ptr2;		//Pointer to function or value
}MENU_ITEM;

#define NO_MENU_ITEMS(x)	(sizeof(x)/sizeof(MENU_ITEM))
#define MENU_TYPE_16BITFLAG		0x80	//If this flag is set, a 16 bit pointer is expected
#define MENU_TYPE_BINFLAG		0x40	//If this flag is set, only 1 and 0 are valid

/* Menu Types to handle */ 
#define MENU_TYPE_DUMMY			0
#define MENU_TYPE_SUBMENU		1		// submenu entry may have a default value struct as item_ptr2!
#define MENU_TYPE_FUNCTION		2
#define MENU_TYPE_PARAMFUNC		3
#define MENU_TYPE_GETVALFUNC	4
#define MENU_TYPE_INFOSTRING    5
//a litte gap for future
#define MENU_TYPE_UINT8			8
#define MENU_TYPE_INT8			9
#define MENU_TYPE_UINT16		(MENU_TYPE_16BITFLAG | 10)
#define MENU_TYPE_INT16			(MENU_TYPE_16BITFLAG | 11)
#define MENU_TYPE_TIMEHHMM		(MENU_TYPE_16BITFLAG | 12)
#define MENU_TYPE_TIMEMS		(MENU_TYPE_16BITFLAG | 13)			//Seconds / ms
#define MENU_TYPE_BIN			(MENU_TYPE_BINFLAG	 | 14)
#define MENU_TYPE_ONOFF			(MENU_TYPE_BINFLAG	 | 15)
#define MENU_TYPE_CHARGE		(MENU_TYPE_BINFLAG	 | 16)
#define MENU_TYPE_STRCYCLE		17
#define MENU_TYPE_TIMECYCLE		(MENU_TYPE_16BITFLAG | 18)
#define MENU_TYPE_EV_SPREAD     (MENU_TYPE_16BITFLAG | 19)		//1 to 4 Ev
#define MENU_TYPE_HDR_IMG		(MENU_TYPE_16BITFLAG | 20)		//only 7 images for now
#define MENU_TYPE_HDR_TIME		(MENU_TYPE_16BITFLAG | 21)		//1/8,1/2,1,2,4,8,16,32s

#define MAX_EV_SPREAD           4       //Max Ev-Spreading for HDR
#define MIN_EV_SPREAD           1       //Min Ev-Spreading for HDR

#define MIN_HDR_IMG				3
#define MAX_HDR_IMG				7

/* function pointer */
typedef uint8_t (*FuncPtr)(void);
FuncPtr FPtr;

typedef int16_t (*BigFuncPtr)(void *);
BigFuncPtr BigFPtr;



//Max rows we can display on OLED
#define MAX_MENU_ROWS	7

void init_menu();
void update_menu();

#endif /* MENU_H_ */